package cn.xx.c;

public class Person {
    private String name = "";
    private int age = 0;
    private String sex = "男";
    public void setSex(String sex) throws ZiDingYiException{
        if (sex.equals("男") || sex.equals("女")){
            this.sex = sex;
        }else{
//            抛出异常  自定义异常
            throw new ZiDingYiException("性别必须是男或者女");
        }
    }
    public void show(){
        System.out.println(this.name + this.sex + this.age );
    }
}
